package o;

import com.huawei.appgallery.agreementimpl.impl.bean.ProtocolQueryResBean;
import java.util.ArrayList;
import java.util.List;

public class aye {
    private static long ॱ = 0;
    private int ˋ;
    private ayi ˏ = ˎ();

    public void ˏ(ayi o_ayi) {
        if (o_ayi != null) {
            this.ˏ = o_ayi;
        }
    }

    public void ˋ() {
        if (ayn.ͺ()) {
            awg.ˎ.ˏ("ProtocolQueryTask", "service is stopped, do not query.");
        } else if (ayn.ˎ() || !ayn.ʻ()) {
            awg.ˎ.ˋ("ProtocolQueryTask", "Enter query.");
            ˊ();
        } else {
            awg.ˎ.ˋ("ProtocolQueryTask", "Enter query, but not need.");
            this.ˏ.ॱ(false);
        }
    }

    private void ˊ() {
        ॱ(new awp(this) {
            final /* synthetic */ aye ˏ;

            {
                this.ˏ = r1;
            }

            public void ˊ(aww o_aww, awy o_awy) {
                if (ayn.ͺ()) {
                    awg.ˎ.ˏ("ProtocolQueryTask", "service is stopped, do not process query response.");
                } else if (o_aww == null || !(o_awy instanceof awv)) {
                    awg.ˎ.ˊ("ProtocolQueryTask", "request or response is null.");
                } else {
                    this.ˏ.ˋ = o_aww.ˏ();
                    this.ˏ.ˋ((awv) o_awy);
                }
            }
        });
    }

    private void ˋ(awv o_awv) {
        awg.ˎ.ˋ("ProtocolQueryTask", "onQueryResult, rtnCode: " + o_awv.ॱ() + ", responseCode: " + o_awv.ˎ());
        if (o_awv.ॱ() == 0 && o_awv.ˎ() == 0) {
            ayn.ˋ();
            ॱ(o_awv);
            return;
        }
        this.ˏ.ॱ();
    }

    private void ॱ(awv o_awv) {
        List<axd> ˊ = o_awv.ˊ();
        awg.ˎ.ˋ("ProtocolQueryTask", "sign records, requestCount: " + this.ˋ + ", responseCount: " + ˊ.size());
        if (ˊ.size() < this.ˋ) {
            this.ˏ.ˊ();
            return;
        }
        List arrayList = new ArrayList();
        int i = 0;
        long j = 0;
        for (axd o_axd : ˊ) {
            int i2;
            j = Math.max(j, o_axd.ॱ());
            if (!o_axd.ʽ()) {
                i2 = i | 1;
            } else if (!o_axd.ˎ() || o_axd.ˋ() == o_axd.ˊ()) {
                i2 = i | 4;
            } else {
                i |= 2;
                arrayList.add(Integer.valueOf(o_axd.ˏ()));
                i2 = i;
            }
            i = i2;
        }
        awg.ˎ.ˋ("ProtocolQueryTask", "signFlags: " + i + ", signTime: " + j);
        ayn.ˎ(j);
        if (i >= 4) {
            this.ˏ.ˊ();
        } else if (i >= 2) {
            this.ˏ.ˋ(arrayList);
        } else {
            this.ˏ.ॱ(true);
        }
    }

    private static ayi ˎ() {
        return new ayi() {
            public void ॱ() {
            }

            public void ˊ() {
            }

            public void ˋ(List<Integer> list) {
            }

            public void ॱ(boolean z) {
            }
        };
    }

    private static void ॱ(awp o_awp) {
        Logger.ˎ("ProtocolQueryTask", "protocolQueryTask start");
        ˋ(new axm(), o_awp);
    }

    private static void ˋ(axm o_axm, awp o_awp) {
        cfw.ˎ(o_axm, new ayh(o_awp));
    }

    private static void ˋ(ProtocolQueryResBean protocolQueryResBean) {
        if (protocolQueryResBean != null) {
            Logger.e("ProtocolQueryTask", "queryNewProDialogShow, response.getErrorCode_():" + protocolQueryResBean.getRtnCode_() + ", response.getErrorMessage_():" + protocolQueryResBean.getErrCause());
        } else {
            Logger.e("ProtocolQueryTask", "query response is null");
        }
    }
}
